package org.example.spring03.config;

import org.example.spring03.conditional.WinCondition;
import org.example.spring03.entity.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class UserConfig {

    @Conditional(WinCondition.class)
    @Bean("bills")
    public User bills(){
        User user = new User();
        user.setName("比尔盖茨");
        return user;
    }

    @ConditionalOnMissingBean(name = "bills")
    @Bean("qbs")
    public User qbs(){
        User user = new User();
        user.setName("乔布斯");
        return user;
    }


    @Bean("u1")
    public User user1() {
        // 创建对象
        User user = new User();
        user.setId(1);
        user.setName("小B");
        user.setAge(18);
        return user;

    }
//    @Bean("u2")
//    public User user2() {
//        User user = new User();
//        user.setId(1);
//        user.setName("小A" );
//        user.setAge(18);
//        return user;
//
//    }


}
